package com.jerry.base.thread;

import lombok.extern.slf4j.Slf4j;

/**
 * User: Jerry
 * Date: 2024/1/31
 * Time: 21:32
 * Description:
 */
@Slf4j
public class MultiThread {

    static class Print implements Runnable {

        private int times = 0;

        @Override
        public void run() {
            while (true) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                log.info("线程{} => 打印了{}次", Thread.currentThread().getName(), ++times);
            }
        }
    }

    public static void main(String[] args) {
        Print print = new Print();

        Thread thread = new Thread(print);
        Thread thread2 = new Thread(print);

        thread.start();
        thread2.start();

    }
}
